package com.ys.fmms.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ys.fmms.mapper.SystemStatusMapper;
import com.ys.fmms.pojo.NodeList;
import com.ys.fmms.pojo.SystemStatus;
import com.ys.fmms.service.NodeListService;
import com.ys.fmms.service.SystemStatusService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Transactional
@Service(value = "systemStatusServiceImpl")
public class SystemStatusServiceImpl extends ServiceImpl<SystemStatusMapper, SystemStatus> implements SystemStatusService {
    @Autowired
    private NodeListService nodeListService;

    @Override
    public SystemStatus getInfo() {
        QueryWrapper<SystemStatus> wrapper = new QueryWrapper<>();
        wrapper.orderByAsc("id");
        SystemStatus systemStatus = baseMapper.selectOne(wrapper);
        NodeList nodeList =  nodeListService.getOnlineAndTotalAmount();
        systemStatus.setOnlineNode(nodeList.getOnlineNode());
        systemStatus.setRegisterNode(nodeList.getRegisterNode());
        return systemStatus;
    }
}
